﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Cart.aspx.cs" Inherits="Golf.WebUI.Cart"
    ValidateRequest="false" %>

<%@ Register Src="~/UserControl/Header.ascx" TagName="Header" TagPrefix="UserHeader" %>
<%@ Register Src="~/UserControl/footer.ascx" TagName="Footer" TagPrefix="UserFooter" %>
<%@ Register Src="~/UserControl/ToolbarContainer.ascx" TagName="Toolbal" TagPrefix="UserToolbal" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../Style/Base.css" rel="stylesheet" type="text/css" />
    <link href="../Style/Cart.css" rel="stylesheet" type="text/css" />
    <link href="../Css/shared-not-home.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">

        window.jQuery || document.write('<script src="../Script/jquery/jquery-1.4.1.min-vsdoc.js" type="text/javascript"><\/script>');
    </script>

    <script src="../Script/jquery.hoverIntent.minified.js" type="text/javascript"></script>

    <script src="../Script/MAD.js" type="text/javascript"></script>

    <style type="text/css">
        #ab_basket1__, #ab_basket1__ div
        {
            float: left;
            display: block;
        }
        #ab_basket1__ .product
        {
            margin-left: 1%;
            width: 32%;
        }
        #ab_basket1__ .price
        {
            padding-left: 22px;
            font-size: 13px;
        }
        #ab_basket1__ .image
        {
            position: static;
            margin-left: 5px;
        }
        #ab_basket1__ .btn_moreInfo
        {
            margin-left: 132px;
        }
        .pRecs
        {
            background-color: white;
            clear: both;
            margin-bottom: 30px;
            margin-left: 0;
            margin-right: 0;
            margin-top: 30px;
            overflow: hidden;
            width: 698px;
        }
        #ab_basket1__ .recsContainer
        {
            border: 1px #cccccc solid;
            border-top: 0;
            height: 155px;
            width: 100%;
        }
        #ab_basket1__ .header
        {
            background-attachment: scroll;
            background-clip: border-box;
            background-color: transparent;
            background-image: url("//www.onlinegolf.co.uk/common/images/basket/headerFooter.png");
            background-origin: padding-box;
            background-position: 0 0;
            background-repeat: no-repeat;
            background-size: auto auto;
            height: 34px;
            padding-bottom: 0;
            padding-left: 10px;
            padding-right: 0;
            padding-top: 3px;
            width: 100%;
        }
        #ab_basket1__ .header h1
        {
            color: #4A4A4A;
            float: left;
            font-size: 1em !important;
            letter-spacing: -1px;
            line-height: 2em;
        }
        .pTitle
        {
            font-size: 0.75em;
            text-align: center;
            height: 42px;
            margin-top: 10px;
            padding: 0 8px;
            width: 100%;
        }
        .recsContainer .product a.btn_moreInfo
        {
            width: 84px;
            height: 0;
            overflow: hidden;
            display: block;
            background: url(../Images/btn_moreinfo.png) no-repeat 0 0;
        }
        .recsContainer .product a:hover.btn_moreInfo
        {
            background-position: 0 -20px;
        }
        .sl
        {
            border: 1px solid #ccc;
            padding: 0px;
            width: 30px;
            text-align: center;
            margin: 0 2px 0 2px;
        }
    </style>

    <script type="text/javascript">
        function changeBar(type, numiid, obj) {
            var txtC = null;
            var change = 0;
            if (type == '+') {
                txtC = obj.previousSibling.previousSibling;
                change = 1;
            }
            if (type == '-') {
                txtC = obj.nextSibling;
                change = -1;
            }
            var num = parseInt(txtC.value);
            if (num + change < 0) {
                alert("The number you entered is already beyond the minimum value");
                return;
            }
            if (num + change > 9999) {
                return;
            }
            txtC.value = num + change;
            changeProductCount(numiid, txtC);
        }

        function changeProductCount(productId, obj) {

            obj.value = trim(obj.value);
            if (obj.value == "") {
                alert("You entered an incorrect format!");
                obj.value = obj.nextSibling.value;
                return;
            }

            if (isNaN(obj.value)) {
                alert("You entered an incorrect format!");
                obj.value = obj.nextSibling.value;
                return;
            }

            if (parseInt(obj.value) == 0) {
                alert("Purchase cannot be '0'");
                obj.value = 1;
            }
            document.getElementById("btn_cha_" + productId).value = parseInt(document.getElementById("btn_cha_" + productId).value);
            $.ajax({
                url: "CartEdit.aspx",
                type: "GET",
                data: "cartid=" + productId + "&count=" + obj.value,
                dataType: "html",
                timeout: 100000,
                cache: false,
                error: function(error) {
                    alert(error);
                },
                success: function(msg) {
                    var str = msg.split('|');
                    SumPriceChange(str[3]);
                    document.getElementById("numchange").value = str[2];
                    document.getElementById("mycart_price_" + productId).innerHTML = document.getElementById("numchange").value;
                }
            });
        }
        function SumPriceChange(ActualPrice) {
            document.getElementById("ActualPrice").innerHTML = "$" + ActualPrice;
        }
        function ShopCartDel(objid) {
            if (confirm('Are you sure remove product?')) {
                sendDelShopCart(objid);
            }
        }
        function sendGetAction(url, myStateChanged) {

            if (xmlHttp == null) {
                xmlHttp = GetXmlHttpObject();
            }

            xmlHttp.onreadystatechange = myStateChanged;
            xmlHttp.open("GET", url, false);
            xmlHttp.send(null);
        }
        var xmlHttp = null;
        function GetXmlHttpObject() {
            var xmlHttp = null;
            try {
                // Firefox, Opera 8.0+, Safari
                xmlHttp = new XMLHttpRequest();
            }
            catch (e) {
                // Internet Explorer
                try {
                    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e) {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
            }
            if (xmlHttp == null)
                alert("Sorry, your browser does not support Ajax");
            return xmlHttp;
        }
        function sendDelShopCart(objid) {
            var url = "CartDel.aspx?id=" + objid;
            sendGetAction(url, GetDelShopCart);
        }
        function GetDelShopCart() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    var responsvalue = xmlHttp.responseText;
                    xmlHttp = null;
                    responsvalue = trim(responsvalue);
                    var responsetext = responsvalue.split('|');
                    switch (responsetext[0]) {
                        case "delcart":
                            window.location.reload();
                            break;
                        default:
                            alert('Unknown error, please contact the administrator!');
                            break;
                    }
                }
            }
        }
        function trim(text1) {
            return text1.replace(/^\s+|\s+$/g, "");
        }
        $(function() {
            $("#lnkClearBasket").click(function() {
                if (confirm('This will remove all products from your basket. Are you sure?')) {
                    var url = "CartDel.aspx?action=ClearBasket";
                    sendGetAction(url, GetDelShopCart);
                }
            });
        });
        
    </script>

</head>
<body>
    <form id="form1" runat="server" style="width: 1004px; margin: 0px auto;">
    <UserHeader:Header ID="UserHeader" runat="server" />
    <div id="mainContent">
        <div class="basketPage">
            <div class="bgHandler">
                <div class="basketContainer">
                    <div class="header">
                        <h1>
                            Your Basket</h1>
                    </div>
                    <div id="updBasket">
                        <div id="basket">
                            <table cellspacing="0" cellpadding="0" style="border: 1px solid gray;">
                                <tbody>
                                    <%if (dt.Rows.Count > 0)
                                      {
                                          for (int i = 0; i < dt.Rows.Count; i++)
                                          {
                                    %>
                                    <tr>
                                        <td class="image">
                                            <a href="../ProductDetail.aspx?id=<%=dt.Rows[i]["id"] %>">
                                                <img src="../ImageProducts/<%=dt.Rows[i]["Pro_Picture"].ToString().Split(',')[0] %>"
                                                    width="60" height="40">
                                            </a>
                                        </td>
                                        <td class="desc">
                                            <h5>
                                                <a href="../ProductDetail.aspx?id=<%=dt.Rows[i]["id"] %>">
                                                    <%=dt.Rows[i]["Pro_Name"]%></a></h5>
                                            <%=dt.Rows[i]["_attr"] %>
                                        </td>
                                        <td class="price">
                                            <p class="priceTxt" style="color: rgb(179, 11, 18);">
                                                <span id="mycart_price_<%=dt.Rows[i]["_Key"].ToString() %>">$<%=getProPrice(dt.Rows[i]["Pro_PromotionPrice"].ToString(), getProNum(dt.Rows[i]["_Key"].ToString()))%></span></p>
                                            <p class="vatTxt" style="color: rgb(137, 188, 5); font-size: 0.9em; font-weight: bold;">
                                              Price  $<%=dt.Rows[i]["Pro_PromotionPrice"]%></p>
                                            <p class="loyaltyTxt">
                                               Save <%=dt.Rows[i]["Pro_Save"]%>%
                                               MRRP <%=dt.Rows[i]["Pro_MarketPrice"]%></p>
                                        </td>
                                        <td align="center">
                                            <a onclick="changeBar('-','<%=dt.Rows[i]["_Key"] %>',this);return false;" href="javascript:void(0)"
                                                title="" clstag="clickcart|keycount|shoppingcartpop|diminish1">
                                                <img alt="" class="jj" src="../images1/pro_buy_inc1.jpg" /></a><input class="sl"
                                                    id="btn_cha_<%=dt.Rows[i]["_Key"] %>" onkeydown="if(event.keyCode == 13) event.returnValue = false"
                                                    onblur="changeProductCount('<%=dt.Rows[i]["_Key"] %>',this);" style="width: 30px"
                                                    maxlength="4" value="<%=getProNum(dt.Rows[i]["_Key"].ToString()) %>" name="txtChange<%=dt.Rows[i]["_Key"] %>" /><input
                                                        type="hidden" value="<%=getProNum(dt.Rows[i]["_Key"].ToString()) %>" name="hidChange<%=dt.Rows[i]["_Key"] %>" /><a
                                                            onclick="changeBar('+','<%=dt.Rows[i]["_Key"] %>',this);return false;" href="javascript:void(0)"
                                                            title="" clstag="clickcart|keycount|shoppingcartpop|add1"><img class="jj" src="../images1/pro_buy_inc2.jpg" /></a>
                                        </td>
                                        <td width="10">
                                            <a href="javascript:void();" onclick="ShopCartDel('<%=dt.Rows[i]["_Key"] %>')">[Remove]</a>
                                        </td>
                                    </tr>
                                    <%}
                                      }
                                      else
                                      {%>
                                    <tr>
                                        <td colspan="6" align="center">
                                            shopping cart is empty
                                        </td>
                                    </tr>
                                    <%}%>
                                </tbody>
                            </table>
                            <input id="numchange" type="hidden" />
                        </div>
                    </div>
                    <ul class="basketLinks">
                        <li><a id="lnkClearBasket" class="basketBtn btn_clearBasket" style="height: 1px;"
                            href="#ClearBasket" title=" Clear Basket"></a></li>
                        <li><a id="lnkContinueShopping" class="basketBtn btn_conShop" href="http://<%= HttpContext.Current.Request.Url.Host %>/index.aspx"
                            style="height: 1px;" title=" Continue Shopping"></a></li>
                    </ul>
                    <div id="ab_basket1__">
                        <div class="pRecs">
                            <div class="header">
                                <h1>
                                    You May Also Like</h1>
                            </div>
                            <div class="recsContainer">
                                <div class="product" prod="81353">
                                    <div class="pTitle">
                                        <a href="header.htm" id="aTitle" title=" Formotion Textured CoolMax Polo Shirt">Formotion
                                            Textured CoolMax Polo Shirt </a>
                                    </div>
                                    <div class="image">
                                        <a href="Index.aspx" title="Formotion Textured CoolMax Polo Shirt">
                                            <img src="http://images.onlinegolf.co.uk/Images/products/upload1/ST/AD/STAD374_1Search.jpg"
                                                id="imgProduct" alt="Formotion Textured CoolMax Polo Shirt" width="105" height="80">
                                        </a>
                                    </div>
                                    <div class="rating norating">
                                    </div>
                                    <div class="price">
                                        PRICE <strong>£24.99</strong></div>
                                    <a href="Index.css" id="aView" class="btn_moreInfo" title="View Formotion Textured CoolMax Polo Shirt">
                                        More Info</a>
                                </div>
                                <div class="product" prod="95543">
                                    <div class="pTitle">
                                        <a href="header.htm" id="aTitle" title=" Stretch Tech Solid Polo Shirt">Stretch Tech
                                            Solid Polo Shirt </a>
                                    </div>
                                    <div class="image">
                                        <a href="GolfProducts.aspx" title="Stretch Tech Solid Polo Shirt">
                                            <img src="http://images.onlinegolf.co.uk/Images/products/upload1/ST/NI/STNI488_1Search.jpg"
                                                id="imgProduct" alt="Stretch Tech Solid Polo Shirt" width="105" height="80">
                                        </a>
                                    </div>
                                    <div class="rating norating">
                                    </div>
                                    <div class="price">
                                        PRICE <strong>£24.99</strong></div>
                                    <a href="Index.aspx" id="aView" class="btn_moreInfo" title="View Stretch Tech Solid Polo Shirt">
                                        More Info</a>
                                </div>
                                <div class="product" prod="83644">
                                    <div class="pTitle">
                                        <a href="Index.aspx" id="aTitle" title=" XFT TP Wedge - Conforming">XFT TP Wedge - Conforming
                                        </a>
                                    </div>
                                    <div class="image">
                                        <a href="header.htm" title="XFT TP Wedge - Conforming">
                                            <img src="http://images.onlinegolf.co.uk/Images/products/upload1/WE/TM/WETM102_1Search.jpg"
                                                id="imgProduct" alt="XFT TP Wedge - Conforming" width="105" height="80">
                                        </a>
                                    </div>
                                    <div class="rating norating">
                                    </div>
                                    <div class="price">
                                        PRICE <strong>£49.99</strong></div>
                                    <a href="Index.css" id="aView" class="btn_moreInfo" title="View XFT TP Wedge - Conforming">
                                        More Info</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="pnlRightContent" class="rightContent">
                    <div id="upTotals" class="border_rightContent" style="padding: 10px;">
                        <dl class="breakdown">
                            <dt>Sub Total</dt><dd>£529.86</dd>
                            <dt>Delivery</dt><dd>-</dd>
                            <dt>Promotional Discount</dt><dd>-</dd>
                            <dt>Loyalty Points</dt><dd>-</dd>
                            <dt>Gift Vouchers</dt><dd>-</dd>
                        </dl>
                        <span class="total">Total</span> <span class="totalPrice" id="ActualPrice" runat="server">
                            0.00</span>
                        <dl class="breakdown">
                            <dt>VAT / Sales Tax (@20%) Included</dt><dd>£88.31</dd>
                        </dl>
                        <dl class="breakdown">
                            <dt>You Save</dt><dd>£104.97</dd>
                        </dl>
                        <a href="#" title="Hide Cost Details" class="toggleBreakdown">Hide cost detail</a>
                        <a id="btnCheckout" class="btn_proceedCheckout" href="/Customers/Account.aspx" style="height: 1px;
                            margin-left: 2px;" title="Proceed To Checkout"></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div style="width: 1px; clear: both;">
    </div>
    <UserFooter:Footer ID="UserFooter" runat="server" />
    <UserToolbal:Toolbal ID="UserToolbal" runat="server" />
    </form>
</body>
</html>

<script type="text/javascript">
    $("a.toggleBreakdown").toggle(function() {
        $("dl.breakdown").slideToggle();
        $(this).html("Show cost detail");
        $(this).toggleClass("open");
        return false;
    }, function() {
        $("dl.breakdown").slideToggle();
        $(this).html("Hide cost detail");
        $(this).toggleClass("open");
        return false;
    });
</script>

